package site.assad.service_tx;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import site.assad.dao.GameDao;
import site.assad.dao.UserDao;
import site.assad.domain.Game;
import site.assad.domain.User;

/**
 * Author: Al-assad 余林颖
 * E-mail: yulinying_1994@outlook.com
 * Date: 2017/12/15 11:37
 * Description: 使用基于aop/tx 进行 xml 事务增强配置
 */
@Service
@Transactional
public class UserService {

    @Autowired
    private UserDao userDao;
    @Autowired
    private GameDao gameDao;

    public User getUser(final int userid){
        User user = null;
        user = userDao.getUserById(userid);
        return user;
    }

    //游戏收集行为
    public void collect(final int userid,final int gameid){
        User user = new User(userid);
        Game game = new Game(gameid);
        userDao.collectGame(user,game);
        gameDao.gameCollected(game,user);
    }


    //public void addUser(..);  省略

    //public void updateUser(..); 省略





}
